function [NormalizedAllData] = Ddavid_normalization(AllData, PositiveOnly)

AllMin = -1.0;
AllCenter = 0.0;
AllMax = 1.0;

NData = size(AllData, 1);
NFeature = size(AllData, 2);
NormalizedAllData = zeros(NData, NFeature);

for FeatureCounter = 1:NFeature
    Mmin = min(AllData(:, FeatureCounter));
    Mmax = max(AllData(:, FeatureCounter));
    NewMin = AllMin;
    NewMax = AllMax;
    if(Mmin >= 0.0)
        Mmin = 0.0;
        NewMin = AllCenter;
    end
    if(Mmax <= 0.0)
        Mmax = 0.0;
        NewMax = AllCenter;
    end
    if(Mmin < 0.0 && Mmax > 0.0)
        if(abs(Mmin) >= Mmax)
            Mmax = abs(Mmin);
        else
            Mmin = (-1.0) * Mmax;
        end
    end
    if(PositiveOnly == true)
        NewMin = 0.0;
        NewMax = 1.0;
    end
    NormalizedAllData(:, FeatureCounter) = (AllData(:, FeatureCounter) - Mmin) ./ ((Mmax - Mmin) / (NewMax - NewMin)) + NewMin;
end
